﻿
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_CF_DeleteCatalog_V2]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_CF_DeleteCatalog_V2];
GO

CREATE PROCEDURE [dbo].[sproc_CF_DeleteCatalog_V2]
    @catalogId    int
AS
BEGIN
SET NOCOUNT ON;

IF EXISTS ( SELECT 1 FROM dbo.UDS_CF_File WHERE CatalogID = @catalogId )
    RETURN 1; -- the catalog is still in use, and cannot be removed.

DELETE FROM dbo.UDS_CF_Catalog WHERE CatalogID = @catalogId;
RETURN 0;

END
GO
